/*
 * @Author: error: git config user.name & please set dead value or install git
 * @Date: 2022-08-31 10:26:21
 * @LastEditors: error: error: git config user.name & please set dead value or install git && error: git config user.email & please set dead value or install git & please set dead value or install git
 * @LastEditTime: 2023-06-28 10:29:42
 * @FilePath: \stm32g431_AllRings\applications\iap_para.h
 * @Description:
 *
 * Copyright (c) 2022 by error: git config user.name && git config user.email & please set dead value or install git, All Rights Reserved.
 */
#ifndef __IAP_PARA_H
#define __IAP_PARA_H

#include <rtthread.h>
#include <board.h>
#include "rtdebug.h"

#define EEPROM_HEAD_CHECK_VALUES 0XEEAABBCC // EE的头参数判断
#define EEPROM_ADDR_SYS_PARA 0X0000
#define EEPROM_ADDR_SYS_PARA_BACK 0X800 // 2K

#define EEPROM_SAVED_PARA_SIZE 128 // 存储参数的空间

enum _RINGS_DEVICE_LIST
{
    RINGS_NO_DEVICE = 0,
    RINGS_RS485_SRT_IM = 0X11,
    RINGS_RS485_EPG_XX = 0x12,
    RINGS_ADC_XX = 0X20,
};

typedef enum
{
    BootFLag_JumpAPP = 0xB5,
    BootFLag_WaitUpgrade = 0x01,

} _BOOTLOADER_FLAG;

/*万能环系统存储参数*/
struct _sys_para
{
    /*需要存储到eeprom,后续参数依次往后添加*/
    uint32_t head_check;                   // 头检查，用于判断EE是否存储过数据
    uint8_t can_id;                        // can-id
    uint8_t upgrate_flag;                  // 升级标志
    enum _RINGS_DEVICE_LIST rings_devices; // 万能环上挂载的设备对象
    uint8_t canfd_broadcast_index;         // FDCAN广播时的索引号
};

union union_sys_savepara
{
    uint8_t data[EEPROM_SAVED_PARA_SIZE];
    struct _sys_para allsys_para;
};

extern union union_sys_savepara allrings_paras; // 万能环系统存储参数
#endif
